package com.xixilala.zh_ad_style

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.ScrollView
import androidx.core.widget.NestedScrollView

class MainActivity : AppCompatActivity() {

    private var isFitXy = true

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val btnToggle: Button = findViewById(R.id.btnChange)
        val adView :ADImageView = findViewById(R.id.adView)
        val scratchCardView :ScratchCardView = findViewById(R.id.scv)

        adView.setImage(R.drawable.p2)

        val svContent: MyScrollView = findViewById(R.id.svContent)
        svContent.setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener {
                v, scrollX, scrollY, oldScrollX, oldScrollY ->
            run {
                adView.setEmptyImageRadius(scrollY.toFloat())
            }
        })

        scratchCardView.setScratchableImage(R.drawable.p2)

        btnToggle.setOnClickListener {
            scratchCardView.reset()
        }





    }
}